<%--
  Created by IntelliJ IDEA.
  User: 17271
  Date: 2022/5/1
  Time: 10:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en" style="width: 100%;height: 100%">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<style type="text/css">
    #top {
        width: 99%;
        height: 60px;
        background: wheat;
        margin: 0 auto;
    }

    #left {
        width: 10%;
        height: 600px;
        background: wheat;
        margin-top: 1%;
        display: inline-block;
    }

    #right {
        width: 90%;
        height: 600px;
    }

    #left, #right {
        float: left;
    }

    /*侧边栏表格*/
    .left {
        height: 50px;
        color: black;
    }

    .left:hover {
        background: azure;
        cursor: pointer;
    }
    #exit{
        margin-top: 10px;
    }
    #exit:hover{
        cursor: pointer;
    }
</style>
<body style="width: 100%;height: 100%;background: #ffffff">
<div id="top">
    <div style="font-size: 46px;height: 100%;width: 30%;display: inline;color: black">
        书&nbsp;籍&nbsp;信&nbsp;息&nbsp;系&nbsp;统
            <div style="float: right;font-size: 24px;margin-top: 10px">当前用户:${user}&nbsp;&nbsp;
        <img id="exit" src="../img/exit.png" height="30px" title="退出" alt="退出">
        </div>
    </div>
</div>

<div style="width: 100%;height: 100%">
    <div id="left">
        <table style="width: 100%;margin-top: 30%;font-size: 24px;text-align:center;display: inline">
            <tr class="left">
                <td id="userManage">&nbsp;用&nbsp;户&nbsp;管&nbsp;理&nbsp;</td>
            </tr>
            <tr class="left">
                <td id="bookmanage">&nbsp;书&nbsp;籍&nbsp;管&nbsp;理&nbsp;</td>
            </tr>
        </table>
    </div>

    <div id="right">
        <iframe id="rightFrame" src="welcome.jsp" width="100%" height="100%" frameborder="0"></iframe>
    </div>
</div>
</body>
<script src="../js/jquery-3.3.1.min.js"></script>
    <script>
        var exit = document.getElementById("exit");
        exit.onclick = function (){
            window.location = "../index.jsp"
        }
        //设置用户管理
        var userManage = document.getElementById("userManage");
        userManage.onclick = function (){
            //判断是否是管理员
            var user = "${user}";
            if (user !== "管理员"){
                //获取右侧框
                var rightFrame = document.getElementById("rightFrame");
                rightFrame.setAttribute("src","authority.jsp")
            }else{
                $.ajax(
                    {
                        url: "http://localhost:8080/booksystem/member",
                        async: true,
                        data: "method=findAllUser" ,
                        type: "GET",
                        dataType: "text",
                        success: function (data) {
                        },
                        error: function () {
                        }
                    }
                )
                //获取右侧框
                var rightFrame = document.getElementById("rightFrame");
                rightFrame.setAttribute("src","user.jsp")
            }
        }
        //设置书籍管理
        var bookmanage = document.getElementById("bookmanage");
        bookmanage.onclick = function (){
            //获取右侧框
            var rightFrame = document.getElementById("rightFrame");
            rightFrame.setAttribute("src","book.jsp");
            //发送ajax请求查询图书信息
            $.ajax({
                url: "http://localhost:8080/booksystem/book",
                async: true,
                data: "method=findAllBook" ,
                type: "GET",
                dataType: "text",
                success: function (data) {
                },
                error: function () {
                }
            })
        }
    </script>
</html>
